<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/bootstrap-3.3.7-dist\css\bootstrap.css">
    <title>Document</title>
</head>

<body>
    <input type="text" id="guess">
    <button onclick="guessNum()" class="btn btn-info">猜</button>
    <span id="guessNum"></span>
    <script>
        var random = parseInt(Math.random() * 10 + 1);
        console.log(random);
        function guessNum() {

            var tempNum = document.getElementById("guess").value;
            var num = parseInt(tempNum);
            var temp = document.getElementById("guessNum");
            if (num > random) {
                temp.innerText = '大了';
            } else if (num < random) {
                temp.innerText = '小了';
            } else {
                temp.innerText = '恭喜您，猜对了';
            }
        }
    </script>
</body>

</html>